public class test {
    public static void main(String[] args) throws InterruptedException{
        for (int i = 0; i < 20; i++) {
            int j=i;
            Thread t1 = new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println(j);
                }
            });
            t1.start();
            t1.join();
        }

        System.out.println("ok");
    }
}
